<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/11 0011
  Time: 下午 4:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>Title</title>

    <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
    <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
    <script src="../../layui-v2.4.5/layui/layui.js" charset="utf-8"></script>
    <script src="../../layui-v2.4.5/layui/layui.js" charset="utf-8"></script>
    <script src="../../layui-v2.4.5/layui/layui.js" charset="utf-8"></script>
    <script src="/plug/province/js/distpicker.data.js"></script>
    <script src="/plug/province/js/distpicker.js"></script>
    <script src="/plug/province/js/main.js"></script>

    <link rel="stylesheet" href="../../layui-v2.4.5/layui/css/layui.css" media="all">
    <link href="http://www.jq22.com/jquery/bootstrap-3.3.4.css" rel="stylesheet">
</head>
<body>
<%--<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;margin-right: 100px"  href="javascript:location.replace(location.href);" title="刷新">--%>
    <%--<i class="layui-icon" style="line-height:30px">ဂ</i></a>--%>

<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">订单号</label>
        <div class="layui-input-block">
            <input type="text" name="id" id="id"
                   disabled="disabled" value="${id}"
                   class="layui-input">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">买家留言</label>
        <div class="layui-input-block">
            <input type="text" name="remark" id="remark"
                    value="${order.remark}"
                   class="layui-input">
        </div>
    </div>




    <div class="layui-form-item">
        <label class="layui-form-label">付款时间</label>
        <div class="layui-input-block">
            <input type="text" name="id"
                   disabled="disabled" value="${order.payTime}"
                   class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">订单状态</label>
        <div class="layui-input-block">

            <select name="state" id="state" lay-verify="">

                <option  <c:if test="${order.state==0}"> selected</c:if> value="0">未支付</option>
                <option <c:if test="${order.state==1}"> selected</c:if> value="1">已支付</option>
                <option <c:if test="${order.state==2}"> selected</c:if> value="2">待收货</option>
                <option <c:if test="${order.state==3}"> selected</c:if> value="3">已完成</option>
                <option <c:if test="${order.state==7}"> selected</c:if> value="7">已删除</option>
                <option <c:if test="${order.state==8}"> selected</c:if> value="8">已取消</option>

            </select>

        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">收货人</label>
        <div class="layui-input-block">
            <input type="text" name="addressName" id="addressName"
                   value="${order.addressName}"
                   class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">收货电话</label>
        <div class="layui-input-block">
            <input type="text" name="addressTel"
                    value="${order.addressTel}" id="addressTel"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">收货地址</label>
        <div class="layui-input-block">
            <input type="text" name="addressTel" disabled="disabled"
                   value="${order.addressInfo}"
                   class="layui-input">
        </div>


    </div>


    <button style="margin-left: 9rem;margin-top: -3rem" type="button" class="layui-btn" onclick="upAddress()">变更收货地址</button>

    <script>

        function upAddress() {
            $("#addressAddress").show();
            $("#saveId").show();

        }




    </script>



</form>

<div  style="float: left;
    display: block;
    padding: 9px 15px; font-weight: 400;font-size: 2rem;display: none" id="addressAddress">
    <div style="display:inline">新的地址</div>
    <div id="distpicker2" style="display:inline">
        <select id="province" >${address.provinceName}</select>
        <select id="city">${address.cityName}</select>
        <select id="district">${address.countyName}</select>
    </div>

        <input type="text" name="detailInfo" id="detailInfo" style="display:inline;margin-left: 7rem;margin-top: 1rem"
                 value="${address.detailInfo}"
                 class="layui-input"  width="5rem">

</div>

<div style="text-align: center" id="saveId">
    <button type="button" class="layui-btn" onclick="saveEditOrder()">保存订单</button>
</div>


<script>
    $("#distpicker2").distpicker({
        province: "${address.provinceName}",
        city: "${address.cityName}",
        district: "${address.countyName}"
    });


    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

    });


    function saveEditOrder() {
        $.ajax({
            url:'/order/saveEditOrder',
            type:'POST', //GET
            async:true,    //或false,是否异步
            data:{
                id:$("#id").val(),
                state:$("#state").val(),
                remark:$("#remark").val(),
                addressInfo:$("#detailInfo").val(),
                addressTel:$("#addressTel").val(),
                addressName:$("#addressName").val(),
                provinceName:$("#province").val(),
                cityName:$("#city").val(),
                countyName:$("#district").val(),
            },
            timeout:5000,    //超时时间
            dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
            beforeSend:function(xhr){
                /*console.log(xhr)
                 console.log('发送前')*/
            },
            success:function(reData){
                if (""!=reData){
                    layer.alert("保存成功", {icon: 6},function () {
                        window.location.reload();

                    });
                }else {
                    layer.alert("保存失败", {icon: 5});
                }
            },
            error:function(xhr,textStatus){
                console.log('错误')
                console.log(xhr)
                console.log(textStatus)
            },
            complete:function(){
                //console.log('结束')
            }
        });

    }


</script>


        </body>

</html>
